{extend name="public:base" /}
{block name="head"}
<link href="__PUBLIC__/view_res/mobile/css/wshop_companyreg.css" type="text/css" rel="Stylesheet" />
<link href="__PUBLIC__/jquery-weui/dist/lib/weui.min.css" type="text/css" rel="Stylesheet" />
<link href="__PUBLIC__/jquery-weui/dist/css/jquery-weui.min.css" type="text/css" rel="Stylesheet" />
<link rel="stylesheet" href="/public/static/js/bt/bootstrap.min.css" />

<link rel="stylesheet" href="/public/static/font-awesome/4.7.0/css/font-awesome.min.css" />
        <!-- ace styles -->

        
<link type="image/x-icon" href="/public/uploads/cache/images/osc1/logo/qrcode_7-16x15.jpg" rel="icon">
<link type="image/x-icon" href="/public/uploads/cache/images/osc1/logo/qrcode_7-16x15.jpg" rel="bookmark">
<link href="/public/static/view_res/mobile/css/product.css" type="text/css" rel="Stylesheet" />
<link href="/public/static/jquery-weui/dist/lib/weui.min.css" type="text/css" rel="Stylesheet" />
<link href="/public/static/jquery-weui/dist/css/jquery-weui.min.css" type="text/css" rel="Stylesheet" />
<script src="/public/static/jquery-weui/dist/js/jquery-weui.min.js"></script>
<script src="/public/static/jquery-weui/dist/js/swiper.min.js"></script>

<script src="__PUBLIC__/jquery-weui/dist/js/jquery-weui.min.js"></script>
<script src="/public/static/js/jquery/jquery-2.1.4.min.js"></script>
<script src="/public/static/Bootstrap/js/bootstrap.min.js"></script>


<script src="/public/static/js/jquery/jquery-migrate-1.2.1.min.js"></script>
            
        
<script src="/public/static/artDialog/artDialog.js"></script>
<link href="/public/static/artDialog/skins/default.css" rel="stylesheet" type="text/css" />         
        
<script>
            
</script>
<script src="/public/static/js/oscshop_common.js"></script>
<link href="__PUBLIC__/view_res/mobile/css/wshop_company_center.css" type="text/css" rel="Stylesheet" />
<link href="__PUBLIC__/view_res/mobile/css/uc.css" type="text/css" rel="Stylesheet" />

{/block} 

{block name="header"}
{include file="public/top-nav" /}
{/block}

{block name="content"}   
<style>
/*.user{
    position: relative;
    color: #444;
    padding-left: 20px;
    line-height: 30px;
    font-size: 14px;

    border-bottom: 1px solid #eee;
    background: url(../images/icon_bar-right.png) 97.5% center no-repeat #fefefe;
    background-size: 15px 16px;
    display: block;
    outline: none;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);}*/
table tr{

    position: relative;
    color: #444;
    padding-left: 50px;
    line-height: 40px;
    font-size: 14px;
    background: url(../images/icon_bar-right.png) 97.5% center no-repeat #fefefe;

}
td{padding-left: 18px;}
.bigrounded {
    -webkit-border-radius: 2em;
    -moz-border-radius: 2em;
    border-radius: 2em;
}
.demo{width:760px; margin:20px auto 0 auto; height:70px;}
.button {
    display: inline-block;
    outline: none;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    font: 16px/100% 'Microsoft yahei',Arial, Helvetica, sans-serif;
    padding: .5em 2em .55em;
    text-shadow: 0 1px 1px rgba(0,0,0,.3);
    -webkit-border-radius: .5em; 
    -moz-border-radius: .5em;
    border-radius: .5em;
    -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.2);
    -moz-box-shadow: 0 1px 2px rgba(0,0,0,.2);
    box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.button:hover {
    text-decoration: none;
}
.button:active {
    position: relative;
    top: 1px;
}
.bigrounded {
    -webkit-border-radius: 2em;
    -moz-border-radius: 2em;
    border-radius: 2em;
}
.medium {
    font-size: 12px;
    padding: .4em 1.5em .42em;
}
.small {
    font-size: 11px;
    padding: .2em 1em .275em;
}


/* blue */
.blue {
    color: #fff!important;
    border-radius: 1px;
    background: -webkit-gradient(linear, left top, left bottom, from(#37485c), to(#37485c));
    background: -moz-linear-gradient(top,  #0078a5,  #00adee);
    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#0078a5', endColorstr='#00adee');
}
.blue:hover {
    color: #80bed6;
    background: -webkit-gradient(linear, left top, left bottom, from(#f5f5f5), to(#f5f5f5));
    background: -moz-linear-gradient(top,  #0078a5,  #00adee);
    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#0078a5', endColorstr='#00adee');
}
.blue:active {
    color: #80bed6;
    background: -webkit-gradient(linear, left top, left bottom, from(#f5f5f5), to(#f5f5f5));
    background: -moz-linear-gradient(top,  #0078a5,  #00adee);
    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#0078a5', endColorstr='#00adee');
}

/* green */
.green {
    color: #e8f0de;
    border: solid 1px #538312;
    background: #64991e;
    background: -webkit-gradient(linear, left top, left bottom, from(#7db72f), to(#4e7d0e));
    background: -moz-linear-gradient(top,  #7db72f,  #4e7d0e);
    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#7db72f', endColorstr='#4e7d0e');
}
.green:hover {
    background: #538018;
    background: -webkit-gradient(linear, left top, left bottom, from(#6b9d28), to(#436b0c));
    background: -moz-linear-gradient(top,  #6b9d28,  #436b0c);
    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#6b9d28', endColorstr='#436b0c');
}
.green:active {
    color: #a9c08c;
    background: -webkit-gradient(linear, left top, left bottom, from(#4e7d0e), to(#7db72f));
    background: -moz-linear-gradient(top,  #4e7d0e,  #7db72f);
    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#4e7d0e', endColorstr='#7db72f');
}

/* white */
.white {
    color: #606060;
    border: solid 1px #b7b7b7;
    background: #fff;
    background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ededed));
    background: -moz-linear-gradient(top,  #fff,  #ededed);
    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ededed');
}
.white:hover {
    background: #ededed;
    background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#dcdcdc));
    background: -moz-linear-gradient(top,  #fff,  #dcdcdc);
    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#dcdcdc');
}
.white:active {
    color: #999;
    background: -webkit-gradient(linear, left top, left bottom, from(#ededed), to(#fff));
    background: -moz-linear-gradient(top,  #ededed,  #fff);
    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#ffffff');
}

/* orange */
.orange {
    color: #fef4e9;
    border: solid 1px #da7c0c;
    background: #f78d1d;
    background: -webkit-gradient(linear, left top, left bottom, from(#faa51a), to(#f47a20));
    background: -moz-linear-gradient(top,  #faa51a,  #f47a20);
    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#faa51a', endColorstr='#f47a20');
}
.orange:hover {
    background: #f47c20;
    background: -webkit-gradient(linear, left top, left bottom, from(#f88e11), to(#f06015));
    background: -moz-linear-gradient(top,  #f88e11,  #f06015);
    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#f88e11', endColorstr='#f06015');
}
.orange:active {
    color: #fcd3a5;
    background: -webkit-gradient(linear, left top, left bottom, from(#f47a20), to(#faa51a));
    background: -moz-linear-gradient(top,  #f47a20,  #faa51a);
    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#f47a20', endColorstr='#faa51a');
}


</style>
<!-- from -->

<form  action="/mobile/financing/exception_process" id="from1" method="post">


    <div style="height: 30pt; line-height: 30pt; text-align: center; background: #fff; color: #f00; border-top: 1px solid #f00; border-bottom: 1px solid #f00;">当前状态：
   {if condition="0 eq $rang_order[0]['exception_state']"}待申请{/if}
   {if condition="1 eq $rang_order[0]['exception_state']"}待处理{/if}
   {if condition="2 eq $rang_order[0]['exception_state']"}审批通过，本轮流程走完{/if}
   {if condition="3 eq $rang_order[0]['exception_state']"}审批不通过{/if}
</div>
{:token()}
<p style="height: 30pt; line-height: 30pt; margin-top: 10px; background: #37485c;">
    <a style="margin-left:30px; font-size: 16px; color: #fff;"><strong>问题描述</strong></a>
</p>
    <input type="hidden" name="rang_num" id="rang_num" value="0" tabindex="4" placeholder="" />
    <div>
        <div class="gs-text">

                <textarea name="exception_desc" rows="4" id="exception_desc" rows="5" style="width: 100%" >{$rang_order[0]['exception_desc']}</textarea> 

        </div>
    </div>
    


{if condition="3 eq $rang_order[0]['delivery']"}
  <div>
        <b style="height: 37px; line-height: 37px; display: block; float: left; border-top: 1px solid #DEDEDE; border-bottom: 1px solid #DEDEDE; background: #FFFFFF; padding-left: 30px; color: #000;">审批意见：</b>
        <div class="gs-text" style="height: 37px; line-height: 37px; color: #f00;">
            {$rang_order[0]['desc']}
        </div>
    </div>
{/if}    
   
<div style="height: 30pt; line-height: 30pt; background: #37485c; margin-top: 20px;">
    <a style="margin-left:10px; font-size: 14px; color: #fff;">
        <strong>图片上传(图片最大5M,最多3张)</strong>
    </a>
</div> 
<div id="1" class="gs-text">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            {if condition="0 eq $rang_order[0]['exception_state']"} 
            <div class="col-sm-3">
                <a href="/mobile/financing/frist" data-toggle="tooltip" title="刷新" id="button-refresh" class="btn btn-default">刷新
                    <i class="fa fa-refresh"></i>
                </a>

                <button type="button" data-toggle="tooltip" title="上传" id="button-upload" class="btn btn-primary">上传
                    <i class="fa fa-upload"></i>
                </button>
                <button type="button" data-toggle="tooltip" title="删除" id="button-delete" class="btn btn-danger">删除
                    <i class="fa fa-trash-o"></i>
                </button>
            </div>
            {/if}
            {if condition="3 eq $rang_order[0]['exception_state']"} 
            <div class="col-sm-3">
                <a href="/mobile/financing/frist" data-toggle="tooltip" title="刷新" id="button-refresh" class="btn btn-default">刷新
                    <i class="fa fa-refresh"></i>
                </a>
                <button type="button" data-toggle="tooltip" title="上传" id="button-upload" class="btn btn-primary">上传
                    <i class="fa fa-upload"></i>
                </button>
                <button type="button" data-toggle="tooltip" title="删除" id="button-delete" class="btn btn-danger">删除
                    <i class="fa fa-trash-o"></i>
                </button>
            </div>
            {/if}
            <table id='1' width="100%" height="150" border="0" cellpadding="0" cellspacing="1">
                <input type="hidden" name="id" id="id" value="{$rang_order[0]['id']}"/>
                <?php if(!empty($img)){ ?>
                <?php foreach ($img as $image) { ?>
                <tr>
                    <td width="50%" align="right">
                        <div class="col-sm-1 text-center">
                            <a href="<?php echo $image['img_path']; ?>"  class="">
                                <img height="120" width="120" src="<?php echo $image['img_path']; ?>" alt="<?php echo $image['file_name']; ?>" title="<?php echo $image['file_name']; ?>" />
                            </a>
                    </td>
                    <td width="50%" align="left">
                        <label>
                            <input type="checkbox" name="path[]" value="<?php echo $image['img_path']; ?>" />
                            <?php echo $image['file_name']; ?>
                        </label>
                          
                    </td>
                </tr>
                <?php } ?>
                <?php } ?>
            </table>

      </div>
    </div>
</div>
{if condition="3 eq $rang_order[0]['exception_state']"}
    <header class="Thead">审批意见</header>
    <div style="padding:0 10px;">
        <div class="gs-text">
            <textarea style="width: 100%;" rows="4">{$rang_order[0]['exception_apply_desc']}</textarea>
           
        </div>
    </div>
    {/if}   

{if condition="0 eq $rang_order[0]['exception_state']"} 
<input type="submit"   class="btn btn-danger" style="width:100%;margin:0 auto; color: #fff!important; position:relative;" value="申请异常处理"/>
{/if}

{if condition="3 eq $rang_order[0]['exception_state']"}  
<div id="appCartWrap" class="clearfix">  
<input type="submit" class="btn btn-danger" style="width:100%;margin:0 auto; color: #fff!important; position:relative;" value="重新申请异常处理"/>
{/if}

</div>


</form>




{/block}
{block name="script"}
<script>
$('#reg-btn').click(function(){
    $.post(
            '{:url("financing/frist")}',    
        $('input[type="text"],input[type="select"],input[type="hidden"]'),
        function(d){
            if(d.error){
                $.toast(d.error, "forbidden");
            }else if(d.success){
                $.toast(d.success);
                //sleep(500);
                              
            }
        }
    );
});

function fileSelected() {
            var file = document.getElementById('fileToUpload').files[0];
            if (file) {
                var fileSize = 0;
                if (file.size > 1024 * 1024)
                    fileSize = (Math.round(file.size * 100 / (1024 * 1024)) / 100).toString() + 'MB';
                else
                    fileSize = (Math.round(file.size * 100 / 1024) / 100).toString() + 'KB';
 
                document.getElementById('fileName').innerHTML = 'Name: ' + file.name;
                document.getElementById('fileSize').innerHTML = 'Size: ' + fileSize;
                document.getElementById('fileType').innerHTML = 'Type: ' + file.type;
            }
        }
 
        function uploadFile() {
            var fd = new FormData();
            fd.append("fileToUpload", document.getElementById('fileToUpload').files[0]);
            var xhr = new XMLHttpRequest();
            xhr.upload.addEventListener("progress", uploadProgress, false);
            xhr.addEventListener("load", uploadComplete, false);
            xhr.addEventListener("error", uploadFailed, false);
            xhr.addEventListener("abort", uploadCanceled, false);
            xhr.open("POST", "Home/Upload");
            xhr.send(fd);
        }
 
        function uploadProgress(evt) {
            if (evt.lengthComputable) {
                var percentComplete = Math.round(evt.loaded * 100 / evt.total);
                document.getElementById('progressNumber').innerHTML = percentComplete.toString() + '%';
            }
            else {
                document.getElementById('progressNumber').innerHTML = 'unable to compute';
            }
        }
 
        function uploadComplete(evt) {
            /* This event is raised when the server send back a response */
            alert(evt.target.responseText);
        }
 
        function uploadFailed(evt) {
            alert("There was an error attempting to upload the file.");
        }
 
        function uploadCanceled(evt) {
            alert("The upload has been canceled by the user or the browser dropped the connection.");
        }   





$('a.directory').on('click', function(e) {
    e.preventDefault();

    $('#modal-image').load($(this).attr('href'));
});
$('.pagination a').on('click', function(e) {
    e.preventDefault();

    $('#modal-image').load($(this).attr('href'));
});
$('#button-parent').on('click', function(e) {
    e.preventDefault();

    $('#modal-image').load($(this).attr('href'));
});

$('#button-refresh').on('click', function(e) {
    e.preventDefault();
    //alert('===');

    //$('#modal-image').load($('#button-refresh').attr('href'));
    window.location.reload();
});

$('input[name=\'search\']').on('keydown', function(e) {
    if (e.which == 13) {
        $('#button-search').trigger('click');
    }
});




$('#button-upload').on('click', function() {

    $('#form-upload').remove();

    $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" value="" /></form>');

    $('#form-upload input[name=\'file\']').trigger('click');

    if (typeof timer != 'undefined') {
        clearInterval(timer);
    }

    timer = setInterval(function() {
        if ($('#form-upload input[name=\'file\']').val() != '') {
            clearInterval(timer);

            var fromdata = new FormData($('#form-upload')[0]);
            //formData.append($('#form1'));
            //var checkValue=$("#exchange_id").val();
            //alert(checkValue);
            var checkValue = jQuery("#exchange_id").val();
            //alert(checkValue);
            //fromdata.append("exchange_id",checkValue);
            fromdata.append("type",4);
            fromdata.append("id",{$rang_order[0]['id']});
            fromdata.append("rang",4);
            fromdata.append("rang_no",0);
            fromdata.append("rang_num",4);
            fromdata.append("trade_no",$("input[name='trade_no']").val());
            fromdata.append("trade_dt",$("input[name='trade_dt']").val());
            fromdata.append("exception_desc",$("textarea[name='exception_desc']").val());
            fromdata.append("delivery_cert1",$("input[name='delivery_cert1']").val());
            fromdata.append("delivery_cert2",$("input[name='delivery_cert2']").val());
            fromdata.append("delivery_cert3",$("input[name='delivery_cert3']").val());
            $.ajax({
                url: "/mobile/financing/upload",
                type: 'post',
                dataType: 'json',
                data: fromdata,
                cache: false,
                contentType: false,
                processData: false,
                beforeSend: function() {
                    $('#button-upload i').replaceWith('<i class="fa fa-circle-o-notch fa-spin"></i>');
                    $('#button-upload').prop('disabled', true);
                },
                complete: function() {
                    $('#button-upload i').replaceWith('<i class="fa fa-upload"></i>');
                    $('#button-upload').prop('disabled', false);
                },
                success: function(json) {
                    if (json['error']) {
                        alert(json['error']);
                    }

                    if (json['success']) {
                        alert(json['success']);

                        $('#button-refresh').trigger('click');
                    }
                },
                error: function(xhr, ajaxOptions, thrownError) {
                    alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                }
            });
        }
    }, 500);
});



$('#button-delete').on('click', function(e) {
    if (confirm('是否要删除')) {
        $.ajax({
            url: "/mobile/financing/delete",
            type: 'post',
            dataType: 'json',
            data: $('input[name^=\'path\']:checked,input[type="hidden"]'),
            beforeSend: function() {
                $('#button-delete').prop('disabled', true);
            },
            complete: function() {
                $('#button-delete').prop('disabled', false);
            },
            success: function(json) {
                if (json['error']) {
                    alert(json['error']);
                }

                if (json['success']) {
                    alert(json['success']);

                    $('#button-refresh').trigger('click');
                }
            },
            error: function(xhr, ajaxOptions, thrownError) {
                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
            }
        });
    }
});
</script>

<script type="text/javascript">
    
        {notempty name='error'}
        
            alert('{$error}');
            window.location.href="/mobile/financing/exception_process";
        
        {/notempty}
</script>

{/block}